package edu.hm.activebadge.rfid.interpretation;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import com.Ostermiller.util.ExcelCSVParser;

import edu.hm.activebadge.rfid.adaption.server.ServerParameter;


public class CSVReader {
	
	ServerParameter params;
	ExcelCSVParser csvParser;
	
	
	public CSVReader(boolean InterpreteOrDetermine){
		params = new ServerParameter();
		try {
			if (InterpreteOrDetermine){
				csvParser = new ExcelCSVParser(new FileInputStream(new File(params.getEntityInterpretationFile())));
				csvParser.changeDelimiter(';');
			}
			else
			{
				csvParser = new ExcelCSVParser(new FileInputStream(new File(params.getActionInterpretationFile())));
				csvParser.changeDelimiter(';');
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public String[] getNextLine() throws IOException{
		return csvParser.getLine();
	}
	
	public static void main(String[] args){
		CSVReader test = new CSVReader(true);
		String[] testArray;
		try {
			testArray = test.getNextLine();
			System.out.println(testArray[0]);
			testArray = test.getNextLine();
			System.out.println(testArray[0]);
			testArray = test.getNextLine();
			System.out.println(testArray[0]);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}

}
